package com.atguigu.gmall.list;

import com.atguigu.gmall.list.bean.Person;
import com.atguigu.gmall.list.dao.PersonDao;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.*;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2024/9/27 5:35
 */
@SpringBootTest
public class PersonSearch {
    @Autowired
    PersonDao personDao;
    @Test
    public void test4(){
        List<Person> all = personDao.findAllByIdGreaterThan(4L);
        for (Person person : all) {
            System.out.println("person = " + person);
        }

    }
    @Test
    public void test3(){
        List<Person> all = personDao.findAllByAddressLike("东京");
        for (Person person : all) {
            System.out.println("person = " + person);
        }

    }

    @Test
    public void test2(){
        Iterator<Person> iterator = personDao.findAll().iterator();
        while (iterator.hasNext()) {
            Person next = iterator.next();
            System.out.println(next);
        }

    }

    @Test
    public void test1(){
        Person person1 = new Person(5L, "泷泽萝拉", "lala@qq.com","东京市11街", new Date());
        Person person2 = new Person(6L, "苍井空", "cangcang@qq.com","东京市13街", new Date());
        Person person3 = new Person(7L, "天海翼", "yiyi@qq.com","东京市12街", new Date());
        Person person4 = new Person(8L, "樱空桃", "taotao@qq.com","东京市16街", new Date());

        List<Person> list = new ArrayList<>();
        list.add(person1);
        list.add(person2);
        list.add(person3);
        list.add(person4);

        personDao.saveAll(list);
    }
}
